# delimit ;
clear ;
cd "replication" ;
set more off ; 

* *******************************************************************************
* re-run endline analysis 
* ******************************************************************************* ;

cd ".." ;
do "./replication/do/table05-endline-behavior.do" ;

* *******************************************************************************
* probit regressions: behavior outcomes
* ******************************************************************************* ;

est drop _all ;

foreach var in $module1_behav $module23_behav $module4_behav $module5_behav  { ;
	probit `var' healthonly healthandpay, robust ;
	est sto Probit`var'; 
} ;

* *******************************************************************************
* logit regressions: behavior outcomes
* ******************************************************************************* ;

foreach var in $module1_behav $module23_behav $module4_behav $module5_behav  { ;
	logit `var' healthonly healthandpay, robust ;
	est sto Logit`var'; 
} ;

* **************************************************************************
* output results from probit
* ************************************************************************** ;

esttab Probit* using "./output/appendix-table-endline-behavior-probit-logit-panelA.tex",
	replace
	drop(_cons)
	eqlabels(none)
	cells(b(label() star fmt(%9.3f %9.3f)) se(par)) 
	star(* 0.10 ** 0.05 *** 0.01) 
	stats(N, fmt(%9.0f) labels("Observations"))
	prehead(\begin{table}[p]\centering \normalsize `"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"'
		\captionsetup{justification=centering} 
		\caption{Effects on Health Behaviors\\Probit and Logit Estimation}
		\label{appendix-table-endline-behavior-probit-logit}
		\setlength{\tabcolsep}{14pt}
		\begin{tabular*}{\hsize}{p{2cm}p{1.7cm}p{1.7cm}p{1.7cm}p{1.7cm}p{1.7cm}p{1.7cm}p{1.7cm}p{1.7cm}}
		\toprule)
	legend label  booktabs  collabels( , none)
	mgroups(
	"\shortstack[c]{Cleanliness\\and Hygiene}"
	"\shortstack[c]{Midwives,\\Maternal \& Child\\Health}"
	"\shortstack[c]{Condoms, AIDS,\\Syphilis}" 
	"\shortstack[c]{Night-\\blindness}"
	, pattern(1 0 0 1 0 1 0 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))
	posthead(\midrule \end{tabular*}
	\bigskip
	\captionsetup[sub]{justification=raggedleft} 
	\subcaption*{\normalsize Panel A: Probit} 
	\vspace{-0.5ex}
	\newcolumntype{C}{>{\centering\arraybackslash}X} \setlength{\tabcolsep}{6pt}
	\begin{tabularx}{\linewidth}{lCCCCCCCC}
	\midrule
	&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)}
	&\multicolumn{1}{c}{(4)} &\multicolumn{1}{c}{(5)} &\multicolumn{1}{c}{(6)}
	&\multicolumn{1}{c}{(7)} &\multicolumn{1}{c}{(8)}
	\\ \midrule)
	postfoot(`"\midrule"'  \end{tabularx}) ;
	
* **************************************************************************
* output results from logit
* ************************************************************************** ;
	
esttab Logit* using "./output/appendix-table-endline-behavior-probit-logit-panelB.tex",
	replace nodepvars nomtitles
	drop(_cons)
	eqlabels(none)
	cells(b(label() star fmt(%9.3f %9.3f)) se(par)) 
	star(* 0.10 ** 0.05 *** 0.01) 
	stats(N, fmt(%9.0f) labels("Observations"))
	prehead(\bigskip
	\subcaption*{\normalsize Panel B: Logit}
	\vspace{-0.5ex}
	\begin{tabularx}{\hsize}{lCCCCCCCC}
	\midrule)
	label booktabs collabels( , none)
	postfoot(`"\midrule"'  \end{tabularx}
	\captionsetup{justification=justified, width=\hsize} 
	\caption*{\footnotesize \textit{Notes:} This table examines the robustness of the results presented in Table \ref{table-endline-behavior} to using probit or logit regression. The specifications do not include randomization strata fixed effects because success or failure is perfectly predicted within some cells. 
	***\$\,p < 0.01$, **\$\,p < 0.05$, *\$\,p<0.10$.
		}
	\end{table}) ;
	
exit ;
